/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.quangtin3.entity;

import java.io.Serializable;
import java.util.List;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Quang
 */
@Entity
@Table(name = "collection_column")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "CollectionColumn.findAll", query = "SELECT c FROM CollectionColumn c"),
    @NamedQuery(name = "CollectionColumn.findById", query = "SELECT c FROM CollectionColumn c WHERE c.id = :id"),
    @NamedQuery(name = "CollectionColumn.findByName", query = "SELECT c FROM CollectionColumn c WHERE c.name = :name"),
    @NamedQuery(name = "CollectionColumn.findByDefaultValue", query = "SELECT c FROM CollectionColumn c WHERE c.defaultValue = :defaultValue"),
    @NamedQuery(name = "CollectionColumn.findByRequired", query = "SELECT c FROM CollectionColumn c WHERE c.required = :required"),
    @NamedQuery(name = "CollectionColumn.findByWidth", query = "SELECT c FROM CollectionColumn c WHERE c.width = :width"),
    @NamedQuery(name = "CollectionColumn.findByPlaceHolder", query = "SELECT c FROM CollectionColumn c WHERE c.placeHolder = :placeHolder")})
public class CollectionColumn implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "ID")
    private Integer id;
    @Size(max = 128)
    @Column(name = "NAME")
    private String name;
    @Size(max = 256)
    @Column(name = "DEFAULT_VALUE")
    private String defaultValue;
    @Column(name = "REQUIRED")
    private Boolean required;
    @Column(name = "WIDTH")
    private Integer width;
    @Size(max = 128)
    @Column(name = "PLACE_HOLDER")
    private String placeHolder;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "collectionColumn")
    private List<SupportDataList> supportDataListList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "collectionColumn1")
    private List<CollectedValue> collectedValueList;
    @JoinColumn(name = "COLUMN_TYPE", referencedColumnName = "ID")
    @ManyToOne(optional = false)
    private ColumnType columnType;
    @JoinColumn(name = "COLLECTION", referencedColumnName = "ID")
    @ManyToOne(optional = false)
    private Collection collection;

    public CollectionColumn() {
    }

    public CollectionColumn(Integer id) {
        this.id = id;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDefaultValue() {
        return defaultValue;
    }

    public void setDefaultValue(String defaultValue) {
        this.defaultValue = defaultValue;
    }

    public Boolean getRequired() {
        return required;
    }

    public void setRequired(Boolean required) {
        this.required = required;
    }

    public Integer getWidth() {
        return width;
    }

    public void setWidth(Integer width) {
        this.width = width;
    }

    public String getPlaceHolder() {
        return placeHolder;
    }

    public void setPlaceHolder(String placeHolder) {
        this.placeHolder = placeHolder;
    }

    @XmlTransient
    public List<SupportDataList> getSupportDataListList() {
        return supportDataListList;
    }

    public void setSupportDataListList(List<SupportDataList> supportDataListList) {
        this.supportDataListList = supportDataListList;
    }

    @XmlTransient
    public List<CollectedValue> getCollectedValueList() {
        return collectedValueList;
    }

    public void setCollectedValueList(List<CollectedValue> collectedValueList) {
        this.collectedValueList = collectedValueList;
    }

    public ColumnType getColumnType() {
        return columnType;
    }

    public void setColumnType(ColumnType columnType) {
        this.columnType = columnType;
    }

    public Collection getCollection() {
        return collection;
    }

    public void setCollection(Collection collection) {
        this.collection = collection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof CollectionColumn)) {
            return false;
        }
        CollectionColumn other = (CollectionColumn) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "org.quangtin3.entity.CollectionColumn[ id=" + id + " ]";
    }
    
}
